<?php

declare(strict_types=1);

namespace App\AdminApi\Module\Admin\Validate;


use Zms\Constants\Database;
use Zms\Validate\ValidateAbstract;

/**
 * 后台菜单验证器
 */
class DepartmentValidate extends ValidateAbstract
{
    public function rules(): array
    {
        return [
            ['id', 'required', 'error' => '数据异常，请刷新重试', 'on' => ['updated']],
            ['id', 'number', 'error' => '数据异常，请刷新重试', 'on' => ['updated']],

            ['name', 'required', 'error' => '请输入{label}', 'on' => ['created', 'updated']],
            ['name', 'string', 'max' => 10, 'error' => '{label}错误', 'on' => ['created', 'updated']],


            ['manage_id', 'required', 'error' => '请选择部门主管', 'on' => ['created', 'updated']],
            ['manage_id', 'int', 'error' => '部门主管选择错误', 'on' => ['created', 'updated']],


            ['pid', 'required', 'error' => '数据异常，请刷新重试', 'on' => ['created']],
            ['pid', 'int', 'error' => '数据异常，请刷新重试', 'on' => ['created']],

            ['remark', 'string', 'max' => 100, 'on' => ['created', 'updated']],

            ['sort', 'number', 'min' => Database::INT_MIN, 'max' => Database::INT_MAX, 'precision' => 0, 'on' => ['created', 'updated']],
        ];
    }


    public function labels(): array
    {
        return [
            'name' => '菜单名称',
            'remark' => '备注信息'
        ];
    }
}